{%include file="index.header.tpl.php"%}
{%include file="index.left.tpl.php"%}
  <!--主要内容开始-->
  <div class="content-wrapper">

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-md-2">
{%include file="file/file.left.tpl.php"%}          <!-- /. box -->
        </div>
        <!-- /.col -->
        <div class="col-md-10">
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">上传文件</h3>
              <!-- /.box-tools -->
            </div>
            <!-- /.box-header -->
             <div class="box-body no-padding">
              <div class="mailbox-controls">
              <form id="form" method="post" action="index.php?a=file.list&file_folder={%$file_folder%}">
				{%$folder_name%}
				<br/>
                <div id="uploader">
                    <p>你的浏览器没有Flash、Silverlight和HTML5的支持。</p>
                </div>
                <br />
                <input type="submit" class="btn btn-primary center-block" value="上传" />
            </form>
              </div>
          </div>
          <!-- /. box -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
{%include file="index.footer.tpl.php"%}
<script src="static/js/plupload.full.min.js"></script>
<script src="static/js/jquery.ui.plupload.js"></script> 
<script type="text/javascript">
// Initialize the widget when the DOM is ready
$(function() {
	$("#uploader").plupload({
		// General settings
		runtimes : 'html5,flash,silverlight,html4',
		url : 'index.php?a=file.upload&file_folder={%$file_folder%}',
		 

		// User can upload no more then 20 files in one go (sets multiple_queues to false)
		max_file_count: 20,
		
		chunk_size: '1mb',

		// Resize images on clientside if we can
		resize : {
			width : 200, 
			height : 200, 
			quality : 90,
			crop: true // crop to exact dimensions
		},
		
		filters : {
			// Maximum file size
			max_file_size : '50mb',
			// Specify what files to browse for
			mime_types: [
				{title : "I files", extensions : "jpg,gif,png,zip,txt,rar,bmp,pdf,doc,docx,ppt,pptx,xls,xlsx"},
			]
		},

		// Rename files by clicking on their titles
		rename: true,
		
		// Sort files
		sortable: true,

		// Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
		dragdrop: true,

		// Views to activate
		views: {
			list: true,
			thumbs: true, // Show thumbs
			active: 'thumbs'
		},

		// Flash settings
		flash_swf_url : 'staic/js/Moxie.swf',

		// Silverlight settings
		silverlight_xap_url : 'staic/js/Moxie.xap'
	});


	// Handle the case when form was submitted before uploading has finished
	$('#form').submit(function(e) {
		// Files in queue upload them first
		if ($('#uploader').plupload('getFiles').length > 0) {

			// When all files are uploaded submit form
			$('#uploader').on('complete', function() {
				$('#form')[0].submit();
			});

			$('#uploader').plupload('start');
		} else {
			alert("请至少选择一个文件.");
		}
		return false; // Keep the form from submitting
	});
});
</script>    
